** Figure A3

clear all
set more off 
capture log close
 
* main path to data
global path "~/Dropbox/Paraguay/1_data/7_replication_dataverse"
capture cd "$path"	

*figures= analysis figures
global figures "$path/figures"

* Load and prepare data
use "$path/data/anr.dta", clear
xtset district_code periods


forval i = 1/9 {
    generate p`i' = (periods == `i')
}

// Generate the 'alt_p' variable and set it to 0
generate alt_p = 0


set more off
eststo clear

** figure A3.a

reghdfe l_anr ///
    i.p1##c.degree_z ///
    p2##c.degree_z ///
    p3##c.degree_z ///
    p4##c.degree_z ///
    p5##c.degree_z ///
    p6##c.degree_z ///
    alt_p ///
    p8##c.degree_z ///
    p9##c.degree_z ///
    , absorb(periods district_code periods#depa) cluster(district_code) nocons
	
set scheme s1mono
coefplot, vertical ///
    omitted ///
    keep(*.p1#c.degree_z *.p2#c.degree_z *.p3#c.degree_z *.p4#c.degree_z *.p5#c.degree_z *.p6#c.degree_z alt_p *.p8#c.degree_z *.p9#c.degree_z) ///
    yline(0, lcolor(red)) ///
    xlabel(1 "1959-1963" 2 "1964-1968" 3 "1969-1973" ///
           4 "1974-1978" 5 "1979-1983" 6 "1984-1988" 7 "1989-1993" 8 "1994-1998" ///
           9 "1999-2003", alternate) ///
    xtitle("Five-year Period", size(3.7) margin(small)) ///
    ytitle("Effect relative to 1989-1993", size(3.7) margin(small)) ///
    ciopts(recast(rcap)) ///
    yscale(range(-0.13 0.26)) ///
    xline(7, lpattern(dash))
	
graph export "$figures/figureA3a.pdf", replace

** figure A3.b

set more off
eststo clear
reghdfe l_anr ///
   i.p1##c.betweenness_z ///
   p2##c.betweenness_z ///
   p3##c.betweenness_z ///
   p4##c.betweenness_z ///
   p5##c.betweenness_z ///
   p6##c.betweenness_z ///
   alt_p ///
   p8##c.betweenness_z ///
   p9##c.betweenness_z ///
   , absorb(periods district_code periods#depa) cluster(district_code) nocons
   
set scheme s1mono
coefplot, vertical ///
   omitted ///
   keep(*.p1#c.betweenness_z *.p2#c.betweenness_z *.p3#c.betweenness_z *.p4#c.betweenness_z *.p5#c.betweenness_z *.p6#c.betweenness_z alt_p *.p8#c.betweenness_z *.p9#c.betweenness_z) ///
   yline(0, lcolor(red)) ///
   xlabel(1 "1959-1963" 2 "1964-1968" 3 "1969-1973" ///
          4 "1974-1978" 5 "1979-1983" 6 "1984-1988" 7 "1989-1993" 8 "1994-1998" ///
          9 "1999-2003", alternate) ///
   xtitle("Five-year Period", size(3.7) margin(small)) ///
   ytitle("Effect relative to 1989-1993", size(3.7) margin(small)) ///
   ciopts(recast(rcap)) ///
   yscale(range(-0.13 0.26)) ///
   xline(7, lpattern(dash))
   
graph export "$figures/figureA3b.pdf", replace
